package com.dadie.dorm.service.impl;




import com.dadie.dorm.dao.IFixDao;
import com.dadie.dorm.dao.impl.FixDaoImpl;
import com.dadie.dorm.pojo.Fix;
import com.dadie.dorm.pojo.query.FixQuery;
import com.dadie.dorm.service.IFixService;
import com.dadie.dorm.util.LayUITableResult;

import java.util.List;

public class FixServiceImpl implements IFixService {
    public IFixDao fixDao=new FixDaoImpl();
    @Override
    public LayUITableResult selectByPage(FixQuery fixQuery) {
        List<Fix> list=fixDao.selectByPage(fixQuery);
        Integer totalCount=fixDao.selectTotalCount(fixQuery);
        return LayUITableResult.ok(totalCount,list);
    }

    @Override
    public boolean deleteById(int id) {
        int count=fixDao.deleteById(id);
        return count==1 ? true: false;
    }

    @Override
    public boolean add(Fix fix) {
        int count=fixDao.add(fix );
        return count==1 ? true: false;
    }



    @Override
    public boolean deleteAll(String[] ids) {
        // delete from fix where id in();
        int count = 0;
        for (String id : ids) {
            count += fixDao.deleteById(Integer.parseInt(id));
        }
        return count == ids.length ? true : false;
    }

    @Override
    public boolean update(Fix fix) {
        int count=fixDao.update(fix);
        return count==1 ? true: false;
    }

    @Override
    public Fix selectById(int id) {
        return fixDao.selectById(id);

    }
}
